<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        p, section{
            display: flex;
            width: 60%;
            height: 150px;
            margin: 0 auto;
        }
        section div:nth-child(1) {
            width: 100px;
            height: 150px;
            background-color: purple;
        }

        /* flex属性定义子项目分配剩余空间，用flex表示占多少份数 */
        section div:nth-child(2){
            flex: 1;
            background-color: green;
        }
        section div:nth-child(3) {
            width: 100px;
            height: 150px;
            background-color: red;
        }

        p{
            margin: 100px auto;
            background-color: pink;
        }
        p span{
            flex: 1;
        }
        p span:nth-child(2){
            flex: 2;
            background-color: green;
        }
    </style>
</head>
<body>
    <section>
        <div>1</div>
        <div>2</div>
        <div>3</div>
    </section>

    <p>
        <span>1</span>
        <span>2</span>
        <span>3</span>
    </p>
</body>
</html>